//
//  ClubExchangeDetailCell.swift
//  77Club
//
//  Created by Apple on 2024/9/18.
//

import UIKit

class ClubExchangeDetailCell: UITableViewCell {
    
    private var bgView = c_make_ex(UIView.self)
        .bgColor(.white).corner(8.0.Scale).end()
    private let timeLabel = c_make_ex(UILabel.self)
        .color("#47494D").font(12.font_medium).end()
    private let stateLabel = c_make_ex(UILabel.self)
        .color("#FF7700").font(12.font_semiBold)
        .alignment(.right).end()
    private var lineView = c_make_ex(UIView.self)
        .bgColor("#F2F3F5").end()
    private let iconImageV = c_make_ex(UIImageView.self)
        .mode(.scaleAspectFill).corner(8).end()
    private let titleLabel = c_make_ex(UILabel.self)
        .color("#2E3033").font(12.font_semiBold).end()
    private let subLabel = c_make_ex(UILabel.self)
        .color("#7B7D80").font(12.font_medium).end()
    private let countLabel = c_make_ex(UILabel.self)
        .color("#FF7700").font(11.font_medium)
        .alignment(.right).end()
    private let rightImageV = c_make_ex(UIImageView.self)
        .mode(.scaleAspectFill).image("Mine_settings_next").end()
    private let lookButton = c_make_ex(UIButton.self)
        .bgColor("#F2F3F5").color("#2E3033")
        .corner(4).text("查看物流").end()

    var model: ClubMyExchangeListModel?{
        didSet{
            guard let md = model else { return }
            
            timeLabel.text = "订单时间：" + md.add_time
            iconImageV.loadImage(url: md.goods_thumb)
            titleLabel.text = md.goods_name
            subLabel.text = "实付款： " + md.order_amount + " 积分"
            countLabel.text = md.goods_num + "件"
            stateLabel.text = md.order_status
        }
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        backgroundColor = .clear
        contentView.backgroundColor = .clear
        
        contentView.subviews{
            bgView.subviews{
                timeLabel
                stateLabel
                lineView
                iconImageV
                titleLabel
                subLabel
                countLabel
                rightImageV
                lookButton
            }
        }
        
        bgView.leading(12.0.Scale).trailing(12.0.Scale).top(12.0.Scale).height(152.0.Scale)
        timeLabel.leading(12.0.Scale).top(12.0.Scale)
        stateLabel.trailing(12.0.Scale).top(12.0.Scale)
        lineView.leading(12.0.Scale).trailing(12.0.Scale).top(36.0.Scale).height(1)
        iconImageV.leading(12.0.Scale).size(60.0.Scale)
        iconImageV.Top == lineView.Bottom + 12.0.Scale
        titleLabel.leading(80.0.Scale).trailing(48.0.Scale)
        titleLabel.Top == lineView.Bottom + 24.0.Scale
        subLabel.leading(80.0.Scale).trailing(48.0.Scale)
        subLabel.Top == titleLabel.Bottom + 14.0.Scale
        countLabel.trailing(12.0.Scale)
        countLabel.CenterY == subLabel.CenterY
        rightImageV.trailing(12.0.Scale).size(16.0.Scale)
        rightImageV.CenterY == titleLabel.CenterY
        lookButton.trailing(12.0.Scale).bottom(12.0.Scale).width(70.0.Scale).height(20.0.Scale)
    }
    
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
